package com.unicdata.twofactorauth.autoconfigure;

import com.unicdata.twofactorauth.config.TwoFactorProperties;
import com.unicdata.twofactorauth.utils.TwoFactorAuthUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 双因子认证工具类
 *
 * @author lhn
 * @date 2025/07/02 13:48
 * @since 1.0.0
 **/
@Configuration
@ConditionalOnClass(TwoFactorAuthUtils.class)
@EnableConfigurationProperties(TwoFactorProperties.class)
public class TwoFactorAutoConfiguration {

    /**
     * 创建TwoFactorAuthUtils Bean
     */
    @Bean
    @ConditionalOnMissingBean
    public TwoFactorAuthUtils twoFactorAuthUtils(TwoFactorProperties properties) {
        return new TwoFactorAuthUtils(properties);
    }

}